import React from 'react'
import { useTranslation } from 'react-i18next';

function Index() {
    const { t, i18n } = useTranslation();
    const changeLanguage=()=>{
        i18n.changeLanguage(i18n.language==='zh' ? 'en' : 'zh')
        console.log(i18n.language)
    }
  return (
    <div>
      <h1>{t('Welcome to React')}</h1>
      <select value={i18n.language} onChange={()=>changeLanguage()}>
        <option value="zh">中文</option>
        <option value="en">英文</option>
      </select>
    </div>
  )
}

export default Index
